package com.pearadmin.pro.modules.mkt.rest;

import com.pearadmin.pro.modules.mkt.domain.MktChannelSource;
import com.pearadmin.pro.common.aop.annotation.Log;
import com.pearadmin.pro.common.constant.ControllerConstant;
import com.pearadmin.pro.common.web.base.BaseController;
import com.pearadmin.pro.common.web.domain.Result;
import  com.pearadmin.pro.modules.mkt.domain.MktChannelSource;
import  com.pearadmin.pro.modules.mkt.param.MktChannelSourceRequest;
import  com.pearadmin.pro.modules.mkt.service.MktChannelSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;


/**
 * 渠道来源Controller
 *
 * @author chenJian
 * @date 2021-09-09
 */
@Api(tags = {"渠道来源"})
@RestController
@RequestMapping(ControllerConstant.ADMIN+"mkt/mktChannelSource")
public class MktChannelSourceController extends BaseController
{
    @Resource
    private MktChannelSourceService mktChannelSourceService;

    /**
     * 查询渠道来源列表
     *  @param request 查询参数
     *  @return {@link Result}
     */
    @GetMapping("/page")
    @Log(title = "渠道来源列表")
    @ApiOperation(value = "渠道来源列表")
    public Result<MktChannelSource> list(MktChannelSourceRequest mktChannelSourceRequest)
    {
        return success(mktChannelSourceService.page(mktChannelSourceRequest));
    }


    /**
     * 新增保存渠道来源
     * @param mktChannelSource 查询参数
     * @return {@link Result}
     */
    @PostMapping("/save")
    @Log(title = "新增渠道来源")
    @ApiOperation(value = "新增渠道来源")
    public Result save(@RequestBody MktChannelSource mktChannelSource)
    {
        return auto(mktChannelSourceService.saveOrUpdate(mktChannelSource));
    }

    /**
     * 查询渠道来源详情
     *
     * @param id 渠道来源ID
     * @return 渠道来源
     */
    @GetMapping("/selectById")
    @Log(title = "查询渠道来源详情")
    @ApiOperation(value = "查询渠道来源详情")
    public Result<MktChannelSource> selectById(@RequestParam Long id)
    {
        return success(mktChannelSourceService.selectMktChannelSourceById(id));
    }



    /**
     * 修改保存渠道来源
     * @param mktChannelSource 查询参数
     * @return {@link Result}
     */
    @PutMapping("/update")
    @Log(title = "修改渠道来源")
    @ApiOperation(value = "修改渠道来源")
    public Result update(@RequestBody MktChannelSource mktChannelSource)
    {
        return auto(mktChannelSourceService.saveOrUpdate(mktChannelSource));
    }


    /**
     * 删除保存渠道来源
     * @param id 查询参数
     * @return {@link Result}
     */
    @DeleteMapping("/remove")
    @Log(title = "删除渠道来源")
    @ApiOperation(value = "删除渠道来源")
    public Result remove(@RequestParam Long id)
    {
        return auto(mktChannelSourceService.removeById(id));
    }

//    /**
//    * 批量删除渠道来源
//    * @param ids 批量删除
//    * @return {@link Result}
//    */
//    @DeleteMapping("removeBatch")
//    @Log(title = "批量删除渠道来源")
//    @ApiOperation(value = "批量删除渠道来源")
//    public Result removeBatch(@RequestParam List<Long> ids){
//        return auto(mktChannelSourceService.removeByIds(ids));
//    }

}
